package edu.ucsd.cs110.mycity;

import android.content.Context;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.util.Log;

/**
 * This class uses the facade pattern to make it extremely simple to play sound effects.
 * 
 * @author Josh
 *
 */
public class SoundFacade {
	
	/*
	 * Pre:  - The Android phone or emulator has speakers
	 *       - The Android phone or emulator has a default notification tone specified
	 *       - cxt != null
	 * Post: - A sound is played through the Android speakers 
	 */
	public static void playNotificationSound(Context cxt) {
		try {
	        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
	        Ringtone r = RingtoneManager.getRingtone(cxt, notification);
	        r.play();
	        Log.i("SoundFacade", "Sound played: " + notification + " as ringtone " + r);
	    } catch (Exception ex) { 
	    	Log.e("SoundFacade",ex.toString());
	    }
	}
}
